/*
package com.itheima.web;

import com.itheima.domain.User;
import com.itheima.servlet.UserServlet;
import com.itheima.servlet.UserServletImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

public class LoginServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Map<String, String[]> map = request.getParameterMap();
        User user = new User();
        try {
            BeanUtils.populate(user,map);
            UserServlet userServlet = new UserServletImpl();
            boolean flag = userServlet.login(user);
            if (flag){
                response.sendRedirect("ListServlet");
            }else{
                response.getWriter().write("添加失败,三秒后跳转");
                response.setHeader("Refresh","3;url=ListServlet");
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
*/
